package com.hxzy.module.back.api.fallback;

import com.hxzy.framework.common.resp.R;
import com.hxzy.framework.common.resp.ResultCode;
import com.hxzy.module.back.api.backaccount.BackFeignApi;
import com.hxzy.module.back.api.backaccount.resp.BackAccountResp;
import feign.hystrix.FallbackFactory;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

/**
 * @Author wy
 * @Description TODO
 * @Date 2024/1/27 9:44
 * @Version 1.0
 */
@Log4j2
@Component
public class BackFeignApiFallbackFactory implements FallbackFactory<BackFeignApi> {
    @Override
    public BackFeignApi create(Throwable throwable) {
        log.error(throwable);
        return new BackFeignApiFallbackFactoryImpl();
    }

    class BackFeignApiFallbackFactoryImpl implements  BackFeignApi{


        @Override
        public R<BackAccountResp> findByAccount(String account) {
            return R.failed(ResultCode.DEMOTION);
        }
    }
}
